#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 18-3-28 下午3:58
# @Author  : huanggz
# @File    : file.py
# @Software: PyCharm
# code is far away from bugs with the god animal protecting
import oss2
import random
import string
import time

auth = oss2.Auth('LTAI0OrY1GUzZxD2', 'G9lgeS1ogDUl1ex6N2pHsmqlmqNGIX')
def put_object_from_file(file, file_name, bucket):

    endpoint ='http://pang5web.oss-cn-beijing.aliyuncs.com/' # 假设你的Bucket处于杭州区域
    bucket = oss2.Bucket(auth, endpoint, bucket, is_cname=True, enable_crc=False)
    bucket.put_object_from_file(file_name, file)

def set_file_name():
    file_name = time.strftime("%Y%m%d%H%M%S", time.localtime()) + '_' + ''.join(
        random.sample(string.ascii_letters + string.digits, 8))

    return file_name